package cn.youth996.nav.controller;

import cn.youth996.nav.service.NominatimService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;
import java.util.Map;

/**
 * @author Zhan Xinjian
 * @date 2025/5/12
 */
@RestController
public class PlaceSearchController {
    @Autowired
    private NominatimService nominatimService;

    @GetMapping("/search")
    public ResponseEntity<?> searchLocation(@RequestParam String query) throws IOException, InterruptedException {
        List<Map<String, Object>> maps = nominatimService.queryLocation(query);
        return ResponseEntity.ok(maps);
    }
}
